package com.zkj.response;

import java.io.IOException;
import java.util.Random;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 禁止浏览器缓存
 * 
 * @author zkj
 * 
 */
public class Servlet_Resp_Demo4 extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		/**
		 * 设置浏览器不要缓存
		 * 
		 */
		resp.setContentType("text/html;charset=utf-8");

		resp.setHeader("Cache-Control", "no-store");
		resp.setHeader("Pragrma", "no-cache");
		resp.setDateHeader("Expires", 0);
		resp.getWriter().write("设置浏览器禁止缓存");
		/**
		 * 对应的html/jsp中引入
		 * 
		 * <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
		 * 
		 * <meta HTTP-EQUIV="pragma" CONTENT="no-cache">
		 * 
		 * <meta HTTP-EQUIV="expires" CONTENT="0">
		 */

	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		doGet(req, resp);

	}

}
